<?php

function showmessage($msg, $url_forward = 'goback', $ms = 1250, $dialog = '', $returnjs = '') {
    echo json_encode(array('statusCode'=>300,'message'=>$msg));
	exit;
}

/**
 * 模板风格列表
 * @param integer $siteid 站点ID，获取单个站点可使用的模板风格列表
 * @param integer $disable 是否显示停用的{1:是,0:否}
 */
function template_list($siteid = '', $disable = 0) {
    $list = glob(APP_PATH.'Home'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
    $arr = $template = array();
    // if ($siteid) {
    //     $site = pc_base::load_app_class('sites','admin');
    //     $info = $site->get_by_id($siteid);
    //     if($info['template']) $template = explode(',', $info['template']);
    // }
    foreach ($list as $key=>$v) {
        $dirname = basename($v);
        // if ($siteid && !in_array($dirname, $template)) continue;
        if (file_exists($v.DIRECTORY_SEPARATOR.'config.php')) {
            $arr[$key] = include $v.DIRECTORY_SEPARATOR.'config.php';
            if (!$disable && isset($arr[$key]['disable']) && $arr[$key]['disable'] == 1) {
                unset($arr[$key]);
                continue;
            }
        } else {
            $arr[$key]['name'] = $dirname;
        }
        $arr[$key]['dirname']=$dirname;
    }
    return $arr;
}